package org.jeecg.modules.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

@Component
public class SeqUtils {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    public Long getNextSeq(String sequenceName) {
        String sql = "SELECT NEXTVAL('" + sequenceName + "')";
        return jdbcTemplate.queryForObject(sql, Long.class);
    }

    public String getNextSeq(String sequenceName, String prefix) {
        String sql = "SELECT NEXTVAL('" + sequenceName + "')";
        return prefix + jdbcTemplate.queryForObject(sql, String.class);
    }
}
